

/*
preferred habitat localization regressions:
robustness with respect to maturity cutoffs

output:
- f3b_*.pdf: localization figures

*/


* plotting options
set scheme lean_uncluttered

* command line option
* set to 1 to re-estimate PH regressions (slow)
if "`1'"=="" {
	local estimate_phregs 0
}
else {
	local estimate_phregs `1'
}



********************************************************************************
********************************************************************************
if `estimate_phregs' == 1 {

* different tau star/cutoff values

use ../data/phreg_clean_auction_notesbonds_govpx_shock_all.dta, clear

* run PH regressions
n di "running regressions: varying tau_star=6"
run_ph_regression D_shock , ///
	mat_var(maturity_remaining) ra_var(high_ra) long_var(term_long) ///
	security_id(cusip_govpx) auction_id(auction_id) ///
	tau_star(6) star_window(2) mat_window(2) mat_long_window(4) mat_step(1) ///
	cluster_type("NT") bw(9) ///
	fname_stub("tau_star6")

n di "running regressions: varying tau_star=10"
run_ph_regression D_shock , ///
	mat_var(maturity_remaining) ra_var(high_ra) long_var(term_long) ///
	security_id(cusip_govpx) auction_id(auction_id) ///
	tau_star(10) star_window(2) mat_window(2) mat_long_window(4) mat_step(1) ///
	cluster_type("NT") bw(9) ///
	fname_stub("tau_star10")

************************
* long/short cutoffs

n di "running regressions: varying long/short cutoffs=8"
* auction terms: indicator for short/long auctions
* 2-7 year and 10-30 year auctions
local trm_cut 8
drop term_long
gen term_long = term_num>`trm_cut'

run_ph_regression D_shock , ///
	mat_var(maturity_remaining) ra_var(high_ra) long_var(term_long) ///
	security_id(cusip_govpx) auction_id(auction_id) ///
	tau_star(3) star_window(2) mat_window(2) mat_long_window(4) mat_step(1) ///
	cluster_type("NT") bw(9) ///
	fname_stub("term_long8")

n di "running regressions: varying long/short cutoffs=4"
local trm_cut 4
drop term_long
gen term_long = term_num>`trm_cut'
run_ph_regression D_shock , ///
	mat_var(maturity_remaining) ra_var(high_ra) long_var(term_long) ///
	security_id(cusip_govpx) auction_id(auction_id) ///
	tau_star(3) star_window(2) mat_window(2) mat_long_window(4) mat_step(1) ///
	cluster_type("NT") bw(9) ///
	fname_stub("term_long4")

}




********************************************************************************
********************************************************************************
* plot

plot_ph_regression, fname_stub("tau_star6") ///
	show_figs(0) figname("f3b_tau_star6") combine_figs(1)

plot_ph_regression, fname_stub("tau_star10") ///
	show_figs(0) figname("f3b_tau_star10") combine_figs(1)

plot_ph_regression, fname_stub("term_long8") ///
	show_figs(0) figname("f3b_term_long8") combine_figs(1)

plot_ph_regression, fname_stub("term_long4") ///
	show_figs(0) figname("f3b_term_long4") combine_figs(1)





